package com.website.web.back.controller.website;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.website.common.annotation.Log;
import com.website.common.enums.BusinessType;
import com.website.custom.domain.WJob;
import com.website.custom.service.IWJobService;
import com.website.common.core.controller.BaseController;
import com.website.common.core.domain.AjaxResult;
import com.website.common.utils.poi.ExcelUtil;
import com.website.common.core.page.TableDataInfo;

/**
 * 人才发展Controller
 * 
 * @author ruoyi
 * @date 2024-12-03
 */
@Controller
@RequestMapping("/back/custom/job")
public class WJobController extends BaseController
{
    private String prefix = "back/website/job";

    @Autowired
    private IWJobService wJobService;

    @RequiresPermissions("system:job:view")
    @GetMapping()
    public String job()
    {
        return prefix + "/job";
    }

    /**
     * 查询人才发展列表
     */
    @RequiresPermissions("system:job:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WJob wJob)
    {
        startPage();
        List<WJob> list = wJobService.selectWJobList(wJob);
        return getDataTable(list);
    }

    /**
     * 导出人才发展列表
     */
    @RequiresPermissions("system:job:export")
    @Log(title = "人才发展", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WJob wJob)
    {
        List<WJob> list = wJobService.selectWJobList(wJob);
        ExcelUtil<WJob> util = new ExcelUtil<WJob>(WJob.class);
        return util.exportExcel(list, "人才发展数据");
    }

    /**
     * 新增人才发展
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存人才发展
     */
    @RequiresPermissions("system:job:add")
    @Log(title = "人才发展", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WJob wJob)
    {
        return toAjax(wJobService.insertWJob(wJob));
    }

    /**
     * 修改人才发展
     */
    @RequiresPermissions("system:job:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        WJob wJob = wJobService.selectWJobById(id);
        mmap.put("wJob", wJob);
        return prefix + "/edit";
    }

    /**
     * 修改保存人才发展
     */
    @RequiresPermissions("system:job:edit")
    @Log(title = "人才发展", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WJob wJob)
    {
        return toAjax(wJobService.updateWJob(wJob));
    }

    /**
     * 删除人才发展
     */
    @RequiresPermissions("system:job:remove")
    @Log(title = "人才发展", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wJobService.deleteWJobByIds(ids));
    }
}
